home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / gnome-vfs-2.0 / libgnomevfs / gnome-vfs-utils.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-01  |  7.3 KB  |  190 lines

  1. /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
  2. /* gnome-vfs-utils.h - Public utility functions for the GNOME Virtual
  3.    File System.
  4.  
  5.    Copyright (C) 1999 Free Software Foundation
  6.    Copyright (C) 2000 Eazel, Inc.
  7.  
  8.    The Gnome Library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU Library General Public License as
  10.    published by the Free Software Foundation; either version 2 of the
  11.    License, or (at your option) any later version.
  12.  
  13.    The Gnome Library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Library General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU Library General Public
  19.    License along with the Gnome Library; see the file COPYING.LIB.  If not,
  20.    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21.    Boston, MA 02111-1307, USA.
  22.  
  23.    Authors: Ettore Perazzoli <ettore@comm2000.it>
  24.            John Sullivan <sullivan@eazel.com> 
  25. */
  26.  
  27. #ifndef GNOME_VFS_UTILS_H
  28. #define GNOME_VFS_UTILS_H
  29.  
  30. #include <glib/gmessages.h>
  31. #include <libgnomevfs/gnome-vfs-file-size.h>
  32. #include <libgnomevfs/gnome-vfs-result.h>
  33. #include <libgnomevfs/gnome-vfs-uri.h>
  34. #include <libgnomevfs/gnome-vfs-handle.h>
  35.  
  36. G_BEGIN_DECLS
  37.  
  38. /**
  39.  * GnomeVFSMakeURIDirs:
  40.  * @GNOME_VFS_MAKE_URI_DIR_NONE: Don't check any directory
  41.  * @GNOME_VFS_MAKE_URI_DIR_HOMEDIR: Check the home directory
  42.  * @GNOME_VFS_MAKE_URI_DIR_CURRENT: Check the current direcotry
  43.  * 
  44.  * Flags that can be passed to gnome_vfs_make_uri_from_input_with_dirs().
  45.  * If the given input might be a relative path it checks for existence of the file
  46.  * in the directory specified by this flag.
  47.  * If both flags are passed the current directory is checked first.
  48.  * 
  49.  **/
  50.  
  51. typedef enum {
  52.     GNOME_VFS_MAKE_URI_DIR_NONE = 0,
  53.     GNOME_VFS_MAKE_URI_DIR_HOMEDIR = 1 << 0,
  54.     GNOME_VFS_MAKE_URI_DIR_CURRENT = 1 << 1
  55. } GnomeVFSMakeURIDirs;
  56.  
  57. /* Makes a human-readable string. */
  58. char *gnome_vfs_format_file_size_for_display (GnomeVFSFileSize  size);
  59.  
  60. /* Converts unsafe characters to % sequences so the string can be
  61.  * used as a piece of a URI. Escapes all reserved URI characters.
  62.  */
  63. char *gnome_vfs_escape_string                (const char      *string);
  64.  
  65. /* Converts unsafe characters to % sequences so the path can be
  66.  * used as a piece of a URI. Escapes all reserved URI characters
  67.  * except for "/".
  68.  */
  69. char *gnome_vfs_escape_path_string           (const char      *path);
  70.  
  71. /* Converts unsafe characters to % sequences so the host/path segment
  72.  * can be used as a piece of a URI.  Allows ":" and "@" in the host
  73.  * section (everything up to the first "/"), and after that, it behaves
  74.  * like gnome_vfs_escape_path_string.
  75.  */
  76. char *gnome_vfs_escape_host_and_path_string  (const char      *path);
  77.  
  78. /* Converts only slashes and % characters to % sequences. This is useful
  79.  * for code that wants to use an arbitrary string as a file name. To use
  80.  * it in a URI, you have to escape again, of course.
  81.  */
  82. char *gnome_vfs_escape_slashes               (const char      *string);
  83.  
  84.  
  85. /* Escapes all the characters that match any of the @match_set */                               
  86. char *gnome_vfs_escape_set              (const char      *string,
  87.                                     const char      *match_set);
  88.  
  89. /* Returns NULL if any of the illegal character appear in escaped
  90.  * form. If the illegal characters are in there unescaped, that's OK.
  91.  * Typically you pass "/" for illegal characters when converting to a
  92.  * Unix path, since pieces of Unix paths can't contain "/". ASCII 0
  93.  * is always illegal due to the limitations of NULL-terminated strings.
  94.  */
  95. char *gnome_vfs_unescape_string              (const char      *escaped_string,
  96.                           const char      *illegal_characters);
  97.  
  98. /* returns a copy of uri, converted to a canonical form */
  99. char *gnome_vfs_make_uri_canonical         (const char     *uri);
  100.  
  101. /* returns a copy of path, converted to a canonical form */
  102. char *gnome_vfs_make_path_name_canonical     (const char      *path);
  103.  
  104. /* returns a copy of path, with initial ~ expanded, or just copy of path
  105.  * if there's no initial ~ 
  106.  */
  107. char *gnome_vfs_expand_initial_tilde         (const char      *path);
  108.  
  109. /* Prepare an escaped string for display. Unlike gnome_vfs_unescape_string,
  110.  * this doesn't return NULL if an illegal sequences appears in the string,
  111.  * instead doing its best to provide a useful result.
  112.  */
  113. char *gnome_vfs_unescape_string_for_display  (const char      *escaped);
  114.  
  115. /* Turn a "file://" URI in string form into a local path. Returns NULL
  116.  * if it's not a URI that can be converted.
  117.  */
  118. char *gnome_vfs_get_local_path_from_uri      (const char      *uri);
  119.  
  120. /* Turn a path into a "file://" URI. */
  121. char *gnome_vfs_get_uri_from_local_path      (const char      *local_full_path);
  122.  
  123. /* Check whether a string starts with an executable command */ 
  124. gboolean gnome_vfs_is_executable_command_string (const char *command_string);
  125.  
  126. /* Free the list, freeing each item data with a g_free */
  127. void   gnome_vfs_list_deep_free               (GList            *list);
  128.  
  129.  
  130. /* Return amount of free space on target */
  131. GnomeVFSResult    gnome_vfs_get_volume_free_space    (const GnomeVFSURI     *vfs_uri, 
  132.                          GnomeVFSFileSize     *size);
  133.  
  134. char *gnome_vfs_icon_path_from_filename       (const char *filename);
  135.  
  136. /* Convert a file descriptor to a handle */
  137. GnomeVFSResult    gnome_vfs_open_fd    (GnomeVFSHandle    **handle,
  138.                      int filedes);
  139.  
  140. /* TRUE if the current thread is the thread with the main glib event loop */
  141. gboolean    gnome_vfs_is_primary_thread (void);
  142.  
  143. /**
  144.  * GNOME_VFS_ASSERT_PRIMARY_THREAD:
  145.  *
  146.  * Asserts that the current thread is the thread with 
  147.  * the main glib event loop 
  148.  **/
  149. #define GNOME_VFS_ASSERT_PRIMARY_THREAD g_assert (gnome_vfs_is_primary_thread())
  150.  
  151. /**
  152.  * GNOME_VFS_ASSERT_SECONDARY_THREAD:
  153.  *
  154.  * Asserts that the current thread is NOT the thread with
  155.  * the main glib event loop 
  156.  **/
  157. #define GNOME_VFS_ASSERT_SECONDARY_THREAD g_assert (!gnome_vfs_is_primary_thread())
  158.  
  159. /* Reads the contents of an entire file into memory */
  160. GnomeVFSResult  gnome_vfs_read_entire_file (const char *uri,
  161.                         int *file_size,
  162.                         char **file_contents);
  163.  
  164. char *   gnome_vfs_format_uri_for_display            (const char          *uri);
  165. char *   gnome_vfs_make_uri_from_input               (const char     *location);
  166. char *   gnome_vfs_make_uri_from_input_with_trailing_ws 
  167.                                                      (const char     *location);
  168. char *   gnome_vfs_make_uri_from_input_with_dirs     (const char     *location,
  169.                               GnomeVFSMakeURIDirs  dirs);
  170. char *   gnome_vfs_make_uri_canonical_strip_fragment (const char          *uri);
  171. gboolean gnome_vfs_uris_match                        (const char          *uri_1,
  172.                               const char          *uri_2);
  173. char *   gnome_vfs_get_uri_scheme                    (const char          *uri);
  174. char *   gnome_vfs_make_uri_from_shell_arg           (const char          *uri);
  175.  
  176.  
  177. #ifndef GNOME_VFS_DISABLE_DEPRECATED
  178. char * gnome_vfs_make_uri_full_from_relative (const char *base_uri,
  179.                           const char *relative_uri);
  180. #endif /* GNOME_VFS_DISABLE_DEPRECATED */
  181.  
  182. GnomeVFSResult gnome_vfs_url_show                        (const char   *url);
  183. GnomeVFSResult gnome_vfs_url_show_with_env               (const char   *url, 
  184.                                                           char        **envp);
  185.  
  186.  
  187. G_END_DECLS
  188.  
  189. #endif /* GNOME_VFS_UTILS_H */
  190.